package managedBean;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;

@ManagedBean(name="UserDisplayManagedBean")
@ViewScoped
public class UserDisplayManagedBean {

    private String email;
    private String password;
    private String confirmPassword;
    private String address;
    private String phoneNumber;
    private String gender;
    private String city;
    private String country;
    private List<String> roles;
    private String securityQuestion;
    private String securityAnswer;
    
    
    public UserDisplayManagedBean() {
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<String> getRoles() {
        return roles;
    }

    public void setRoles(List<String> roles) {
        this.roles = roles;
    }

    public String getSecurityAnswer() {
        return securityAnswer;
    }

    public void setSecurityAnswer(String securityAnswer) {
        this.securityAnswer = securityAnswer;
    }

    public String getSecurityQuestion() {
        return securityQuestion;
    }

    public void setSecurityQuestion(String securityQuestion) {
        this.securityQuestion = securityQuestion;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
        
    public void doDisplay(PhaseEvent event) {
         FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        try {
            if (email == null) {
                email = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("email");
            }
            if (password == null) {
                password = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("password");
            } 
            if (confirmPassword == null) {
                confirmPassword = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("confirmPassword");
            } 
            if (address == null) {
                address = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("address");
            } 
            if (phoneNumber == null) {
                phoneNumber = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("phoneNumber");
            } 
            if (gender == null) {
                gender = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("gender");
            } 
            if (city == null) {
                city = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("city");
            } 
            if (country == null) {
                country = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("country");
            } 
            if (roles == null) {
                roles = (List<String>) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("roles");
            } 
            if (securityQuestion == null) {
                securityQuestion = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("securityQuestion");
            }
            if (securityAnswer == null) {
                securityAnswer = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("securityAnswer");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
